package cn.edu360t.Tags
import org.apache.commons.lang3.StringUtils
import org.apache.spark.sql.Row
object Tags4Ads extends Tags {

  override def makeTags(args: Any*): Map[String, Int] = {

    var map = Map[String, Int]()
    val row = args(0).asInstanceOf[Row]

    // 逻辑
    val adSpt = row.getAs[Int]("adspacetype")
    if (adSpt > 0 && adSpt < 10) map += (("LC0" + adSpt, 1)) else map += "LC" + adSpt -> 1
    val adSptn = row.getAs[String]("adspacetypename")
    if (StringUtils.isNotEmpty(adSptn)) map += "LN" + adSptn -> 1


    // 渠道
    val channelId = row.getAs[Int]("adplatformproviderid")
    if (channelId > 0) map += "CN" + channelId -> 1

    map
  }
}
